#ifndef TCPSERVER_H
#define TCPSERVER_H

#include <QWidget>
#include <QTcpServer>
#include <QTcpSocket>
namespace Ui {
class TCPserver;
}

class TCPserver : public QWidget
{
    Q_OBJECT

public:
    explicit TCPserver(QWidget *parent = nullptr);
    ~TCPserver();
private:
    QTcpServer *tcpServer;              //ＴＣＰ服务器
    QTcpSocket *tcpSocket = nullptr;    //TCP通信的ｓｃｏｃｋｅｔ
    QString getLocalIP();               //获取本机ｉｐ地址
signals:
    void show_Menu();
private slots:
    void do_newConnection();            //关联QTcpServer的newConnection信号
    void do_socketStateChange(QAbstractSocket::SocketState socketState);
    void do_clientconnected();          //客户端socket已连接
    void do_clientDisconnected();       //客户端socket已断开
    void do_socketReadyRead();          //读取ｓｏｃｋｅｔ传入的数据
    void on_actStart_clicked();

    void on_actStop_clicked();

    void on_btnSenf_clicked();

    void on_pushButton_4_clicked();

private:
    Ui::TCPserver *ui;
};

#endif // TCPSERVER_H
